package com.zretc.kscxmz.services.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zretc.kscxmz.entity.infor.InformEntity;
import com.zretc.kscxmz.mappers.InformMapper;
import com.zretc.kscxmz.services.InformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InformSerivceImpl implements InformService {

    @Autowired
    private InformMapper informMapper;
    @Override
    public boolean insert(InformEntity informEntity) {
        int insert = informMapper.insert(informEntity);
        if (insert>0){
            return true;
        }
        return false;
    }


    public PageInfo<InformEntity> findList(int pageNum, int pageSize){

        /*开始分页*/
        PageHelper.startPage(pageNum, pageSize);
        List<InformEntity> list = informMapper.findList();
        /*将list包装到pageinfo对象中去*/
        PageInfo<InformEntity> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }


    /*根据标题模糊查询数据，遍历*/

    @Override
    public PageInfo<InformEntity> findAllList(int pageNum, int pageSize, InformEntity BiaoTi) {
        /*开始分页*/
        PageHelper.startPage(pageNum,pageSize);
        List<InformEntity> allList = informMapper.findAllList(BiaoTi);
        PageInfo<InformEntity> pageInfo = new PageInfo<>(allList);
        return pageInfo;
    }


    @Override
    public boolean delctByid(Integer typeId) {

        int i = informMapper.delctByid(typeId);
        if (i>0){
            return true;
        }
        return false;
    }

    @Override
    public InformEntity selectByidList(Integer id) {

        InformEntity list = informMapper.selectByidList(id);

        return list;
    }

    @Override
    public Boolean updateByid(InformEntity informEntity) {
        int update = informMapper.updateByid(informEntity);
        if (update>0){
            return true;
        }
        return false;
    }

    @Override
    public InformEntity selectByid(Integer id) {
        InformEntity informEntity = informMapper.selectByid(id);
        return informEntity;
    }



}
